<template>
  <div class="app-container">
    <el-row :gutter="20">
      <el-col>
        <!-- 查询 -->
        <el-form ref="orderData" :model="orderData" size="small" :inline="true" label-width="68px">
          <el-form-item label="订单状态">
            <el-select v-model="orderData.orderStatus" placeholder="请选择订单状态">
              <el-option v-for="item in orderType" :label="item.label" :value="item.value"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="选择时间">
            <el-date-picker v-model="tiemValue" type="daterange" value-format="yyyy-MM-dd" range-separator="--"
              start-placeholder="开始日期" end-placeholder="结束日期" :default-time="['00:00:00', '23:59:59']"
              @change="changeTime">
            </el-date-picker>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="onSubmitsear" icon="el-icon-search" size="mini">查询</el-button>
            <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
          </el-form-item>
        </el-form>
       <!-- <download-excel class="export-excel-wrapper" :fetch="createExportData" header="订单数据统计" :data="dataList">
          <el-button type="warning" size="mini" plain icon="el-icon-download"> 导出 </el-button>
        </download-excel> -->
        <!-- 改价列表 -->
        <el-table v-loading="loading" :data="tableData" ref="tableRef" border style="width: 100%" class="mb20">
          <el-table-column prop="capsuleInfoTitle" label="项目" align="center">
          </el-table-column>
          <el-table-column prop="capsuleRoomName" label="房间" align="center" width="160">
          </el-table-column>
          <el-table-column prop="changeBeforeRealPrice" label="改价前价格" align="center" width="110">
            <template slot-scope="scope">
              <div style="color: #e45656;">{{scope.row.changeBeforeRealPrice}}元</div>
            </template>
          </el-table-column>
          <el-table-column prop="changeAfterRealPrice" label="改价后价格" align="center" width="110">
            <template slot-scope="scope">
              <div style="color: #e45656;">{{scope.row.changeAfterRealPrice}}元</div>
            </template>
          </el-table-column>
          <el-table-column prop="otherPayPrice" label="三方支付价格" align="center" width="160">
            <template slot-scope="scope">
              <div style="color: #e45656;">{{scope.row.otherPayPrice}}元</div>
            </template>
          </el-table-column>
          </el-table-column>
          <el-table-column prop="changeReason" label="改价原因" align="center">
          </el-table-column>
          <el-table-column prop="changeSourceType" label="改价来源" align="center" width="100">
            <template slot-scope="scope">
              <div>
                {{scope.row.changeSourceType == 0 ? '美团' : (scope.row.changeSourceType == 1 ? '抖音' : (scope.row.changeSourceType == 2 ? '携程' :'其它'))}}
              </div>
            </template>
          </el-table-column>
          <el-table-column prop="changePriceTime" label="改价时间" align="center" width="210">
          </el-table-column>
          <el-table-column prop="roomChangeStatus" label="是否改价" align="center">
          </el-table-column>
          <el-table-column prop="orderStatus" label="订单状态" align="center">
          </el-table-column>
          <el-table-column prop="useRoomStatus" label="订单使用状态" align="center">
          </el-table-column>
          <el-table-column prop="checkInTime" label="入住时间" align="center">
          </el-table-column>
          <el-table-column prop="checkOutTime" label="退房时间" align="center">
          </el-table-column>







        </el-table>
        <el-pagination background align='right' @size-change="handleSizeChange" @current-change="handleCurrentChange"
          :current-page="fromData.pageNum" :page-size="fromData.pageSize" layout="prev, pager, next" :total="total">
        </el-pagination>
      </el-col>
    </el-row>
  </div>
</template>

<script>
  import {
   getPriceChangeList,
   getExcelPrice
  } from "@/api/order/order"
  export default {
    data() {
      return {
        loading: true,
        tableData: [],
        total: 0,
        orderData: {},
        orderStatus: '',
        orderType: [{
            value: 0,
            label: '下单'
          },
          {
            value: 1,
            label: '已支付'
          },
          {
            value: 2,
            label: '已退款'
          },
          {
            value: 3,
            label: '已取消'
          },
          {
            value: 99,
            label: '全部'
          }
        ],
        tiemValue: '',
        fromData: {
          capsuleInfoId: '',
          createBeginTime: '',
          createEndTime: '',
          orderStatus: 99,
          pageNum: 1,
          pageSize: 10
        }

      }
    },
    created() {
      this.getPriceChangeList()
    },
    methods: {
      getPriceChangeList() {
        this.loading = true
        let capsuleInfoId = this.$store.state.user.capsuleInfoId
        this.fromData.capsuleInfoId = capsuleInfoId == null ? '' : capsuleInfoId
        getPriceChangeList(this.fromData).then(res => {
          // console.log('finace-->' , res)
          if (res.code == 200) {
            let data = res.data
            this.tableData = data.rows
            this.total = data.total
            this.loading = false
          }
        })
      },
      handleSizeChange(val) {
        this.fromData.pageNum = val
        this.getPriceChangeList()
      },
      handleCurrentChange(val) {
        this.fromData.pageNum = val
        this.getPriceChangeList()
      },
      changeTime(e) {
        this.fromData.createBeginTime = this.tiemValue[0]
        this.fromData.createEndTime = this.tiemValue[1]
      },
      onSubmitsear() {
        this.getPriceChangeList()
      },
      resetQuery() {
        this.fromData = {
          capsuleInfoId: '',
          createBeginTime: '',
          createEndTime: '',
          orderStatus: 99,
          pageNum: 1,
          pageSize: 10
        }
        this.tiemValue = ''
        this.getPriceChangeList()
      },
      onExamine(id) {
        this.id = id
        this.refundVisibles = true
      },
      refundClose() {
        this.refundVisibles = false
      }
    }
  }
</script>

<style lang="scss">

</style>
